package com.qding.park.manager.timer.schedule.job;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.JobKey;

import com.qding.park.common.core.constant.CacheKeyThree;
import com.qding.park.common.core.redis.JedisClient;
import com.qding.park.common.core.redis.SerializeUtils;
import com.qding.park.manager.pojo.queue.QueueMsg;
import com.qding.park.manager.pojo.queue.QueueTypeEnum;
import com.qding.park.manager.timer.ParkTimerApplication;


/**
 * @ClassName DataConsistencyCheckJob
 * @Description TODO(数据一致性检查任务)
 * @author Administrator
 * @Date 2016年9月15日 下午4:22:56
 * @version 1.0.0
 */
public class DataConsistencyCheckJob extends AbstractJob {
	private static final Log _log = LogFactory.getLog(DataConsistencyCheckJob.class);
	

	@Override
	public void execJob(JobExecutionContext context) {
		JobKey jobKey = context.getJobDetail().getKey();
		
		// 得到redis client
		JedisClient jedisClient = ParkTimerApplication.ctxUtil.getApplicationContext().getBean(JedisClient.class);
		
		//数据一致性检查任务
		QueueMsg  dataConsistencySyncMsg=new QueueMsg();
		dataConsistencySyncMsg.setEventType(QueueTypeEnum.DATA_IDENTICAL.getType());
		String dataConsistencySyncStr=SerializeUtils.serialize(dataConsistencySyncMsg);
		//数据一致性检查　消息
		jedisClient.lpush(CacheKeyThree.QUEUE_ALL, dataConsistencySyncStr);
		
		
		try {
			Thread.sleep(1000*60*5);
		} catch (InterruptedException e) {
			_log.error(e, e);
		}
		
		_log.info("数据一致性检查任务: " + jobKey + " executing at " + new Date());

	}
}
